<template>
  <div>
    <div class="mui-numbox" data-numbox-min="1">
      <button class="mui-btn mui-numbox-btn-minus" type="button">-</button>
      <input class="mui-numbox-input" type="number" @change="countchend">
      <button class="mui-btn mui-numbox-btn-plus" type="button">+</button>
    </div>
  </div>
</template>
<script>
import mui from "../../assets/lib/js/mui.min.js"
export default {
  data(){
    return{

    }
  },
  mounted() {
    mui(".mui-numbox").numbox();
  },
  methods:{
    countchend(){
      var value=mui(".mui-numbox").numbox().getValue()
      console.log(value);
      this.$emit("shopings",parseInt(value))
    }
  },
  props:["kucun"],
  watch:{
    //监听最大值,因为是异步获取的,不知道什么时候能获取到最大值
    kucun:function(newVal,oldVal){
      mui(".mui-numbox").numbox().setOption('max',newVal)
    }
  }

};
</script>
<style lang="less" scoped>
</style>